/**
 * 
 */
package com.necsv;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;

import com.necsv.Mylog.Mylog;
import com.necsv.Mylog.Mytoast;

/**
 * @author THANHSON
 * this class show menu of all function of tutorial
 */
public class MenuActivity extends ListActivity {

	final static String INTENT = "intent";
	final static String IMPLICIT_INTENT = "Implicit intent";
	final static String SQLITE1 = "SQLite1";
	static final String PREFERENCES = "preferences";
	static final String MAP = "maps";
	static final String Spinner = "SPINNER & SharePrefs";
	private static final String SIMPLE_TAB_ACTIVITY = "SimpleTabActivity";
	private static final String TUTORIAL1 = "Tutorial1";
	private static final String WALLPAPER_APP = "Wallpaper App";
	private static final String CUSTOMDIALOG = "Custom Dialog";
	private static final String CHECK_INSTALL = "Check Install";
	private static final String DRAG_DROP = "Drag_Drop";
	private static final String BROADCAST = "BroadCast";
	private static final String WEBVIEW = "Webview";
	protected static final String ADMOB = "Admob";
	private static final String SQLITE = "Sqlite";
	private static final String WEBCUSTOM = "WebViewCustom";
	private static final String TODOLIST = "TodoList";
	private static final String SHARE_ON_FB = "share_on_facebook";
	private static final String FACEBOOK = "facebook";
	private static final String PREFERENCE_SCREEN = "PREFERENCE_SCREEN";
	private static final String TOGGLE_BUTTON = "Toggle Button";
	private static final String TABHOST2 = "Tabhost From Manifest";
	
	static String[]listAction = new String[]{TABHOST2,TOGGLE_BUTTON,PREFERENCE_SCREEN,FACEBOOK ,SHARE_ON_FB,TODOLIST,WEBCUSTOM,SQLITE,ADMOB,TUTORIAL1,SIMPLE_TAB_ACTIVITY, WALLPAPER_APP,CUSTOMDIALOG, CHECK_INSTALL,
		DRAG_DROP, BROADCAST, WEBVIEW};
	ArrayAdapter<String>adapter;
	Mytoast mytoast;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        mytoast = new Mytoast(this);
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listAction);
        setListAdapter(adapter);
        getListView().setBackgroundDrawable(getResources().getDrawable(R.drawable.huyen));
        getListView().setOnItemClickListener(new OnItemClickListener() {

			

			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				String s = getListView().getItemAtPosition(arg2).toString();
				Intent intent = new Intent();
				if(s.equals(TABHOST2)){
					intent = new Intent(getBaseContext(), TabHostActivity.class);
				}
				if(s.equals(SIMPLE_TAB_ACTIVITY))
				{
					GoogleAnaTool.trackEvent(SIMPLE_TAB_ACTIVITY, "simple action", "simple label", 10);
					intent = new Intent(getBaseContext(), SimpleTabActivity.class);
				}
				if(s.equals(TUTORIAL1))
				{
					GoogleAnaTool.trackEvent(TUTORIAL1, "simple action", "simple label", 10);
					intent = new Intent(getBaseContext(), Tutorial1Activity.class);
				}
				if(s.equals(WALLPAPER_APP))
				{
					intent = new Intent(getBaseContext(), WallPaperActivity.class);
				}
				if(s.equals(CUSTOMDIALOG))
				{
					GoogleAnaTool.trackEvent(CUSTOMDIALOG, "simple action", "simple label", 10);
					intent = new Intent(getBaseContext(), CustomDialogActivity.class);
				}
				if(s.equals(CHECK_INSTALL))
				{
					intent = new Intent(getBaseContext(),CheckInstallActivity.class);
				}
				if(s.equals(DRAG_DROP))
				{
					intent = new Intent(getBaseContext(), DrapDropActivity.class);
				}
				if(s.equals(BROADCAST))
				{
					intent = new Intent(getBaseContext(), BroadcastActivity.class);
				}
				if(s.equals(WEBVIEW))
				{
					intent = new Intent(getBaseContext(),WebviewActivity.class);
				}
				if(s.equals(ADMOB))
				{
					intent = new Intent(getBaseContext(),AdMobActivity.class);
				}
				if(s.equals(SQLITE))
				{
					intent = new Intent(getBaseContext(),SqliteActivity.class);
				}
				if(s.equals(WEBCUSTOM))
				{
					intent = new Intent(getBaseContext(),WebviewCustomActivity.class);
				}
				if(s.equals(TODOLIST))
				{
					intent = new Intent(getBaseContext(),TodoListSqliteActivity.class);
				}
				if(s.equals(SHARE_ON_FB))
				{
					intent = new Intent(getBaseContext(),ShareToFacebookActivity.class);
				}
				
				if(s.equals(PREFERENCE_SCREEN))
				{
					intent = new Intent(getBaseContext(),PreferenceScreenActivity.class);
				}
				
				if(s.equals(TOGGLE_BUTTON))
				{
					intent = new Intent(getBaseContext(),ToggleButtonCustomActivity.class);
				}
				startActivity(intent);
			}
		});
        
//        final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
//
//        String deviceid = tm.getDeviceId();
//        Log.v("menu",deviceid);
        
    }
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		super.onCreateOptionsMenu(menu);
		MenuInflater menuInflater = getMenuInflater();
		menuInflater.inflate(R.menu.menuinit, menu);
		return true;
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case R.id.item1:
			//Mylog.Toat(this, "Item 1");
			startActivity(new Intent(this, MenuInitActivity.class));
			Log.v("tag", "Item 1");
			break;
		case R.id.item2:
			Mylog.Toat(this, "Item 2");
			break;

		default:
			break;
		}
		return false;
	}
	
}
